<?php
/**
 * +----------------------------------------------------------------------
 * | 九月科技-ztuc.cn
 * +----------------------------------------------------------------------
 *                      .::::.
 *                    .::::::::.            | AUTHOR: siyu
 *                    :::::::::::           | EMAIL: ztucke@ztuc.cn
 *                 ..:::::::::::'           | DATETIME: 2020/01/31
 *             '::::::::::::'
 *                .::::::::::
 *           '::::::::::::::..
 *                ..::::::::::::.
 *              ``::::::::::::::::
 *               ::::``:::::::::'        .:::.
 *              ::::'   ':::::'       .::::::::.
 *            .::::'      ::::     .:::::::'::::.
 *           .:::'       :::::  .:::::::::' ':::::.
 *          .::'        :::::.:::::::::'      ':::::.
 *         .::'         ::::::::::::::'         ``::::.
 *     ...:::           ::::::::::::'              ``::.
 *   ```` ':.          ':::::::::'                  ::::..
 *                      '.:::::'                    ':'````..
 * +----------------------------------------------------------------------
 */
/**
 * Created by PhpStorm.
 * ClickLog: Administrator
 * Date: 2020/3/14
 * Time: 17:18
 */

namespace app\lnadmin\controller;
use app\core\InitController;
use think\facade\View;
use app\lnadmin\model\admin\ClickLog as ClickLogModel;
use app\lnadmin\model\admin\User as U;
use app\store\controller\Index;
class ClickLog extends InitController
{

    // 列表
    public function list()
    {
        return View::fetch('clicklog', ['user_name'=>Index::cars()['car']]);
    }

    // 数据
   public function index_json($limit='15')
    {
        $list = ClickLogModel::order('id desc')->paginate($limit);
       //获取用户信息
        if(!empty($list)) {
            foreach ($list as $k => $v) {
                if ($v['user_id']) {
                   $userInfo = U::findUser($v['user_id']);
                   $list[$k]['user_id'] = $userInfo['username']; 
                
                   $list[$k]['user_name'] = Index::cars()['car'];   //获取游客信息 
                   }
                }
            }
        $this->result($list);
    }


    // 删除
    public function del()
    {
        if ($this->request->isPost()) {
        $param = $this->request->param();
        $result = ClickLogModel::del($param['id']);
         if ($result == true) {
            add_admin_log('del', '点赞');// 记录行为日志
                return $this->success('', '', '删除成功');
            }
        }
    }
}